import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

import routeData from "@/data/routeData"
Vue.use(VueRouter);

//导航守卫 guard 函数 aop 拦截器 过滤器 钩子函数

const router = new VueRouter({
  routeData,
});
routeData.forEach(r =>{
  router.addRoute(r);
})


router.beforeEach((to, from, next) => {
  console.log("用户从", from.path);
  console.log("用户将要去" + to.path);
  // if (to.path === "/fourth") {
  //   next("/first")
  // }
  next();
});
export default router;
